package sevensoft.行为型模式.访问者模式;

import lombok.Data;

import java.util.*;

/***
 * 对象结构
 */
public class Home {

    private final List<Animal> animalList = new ArrayList<>();

    public <T extends Animal> void add(T animal) {
        this.animalList.add(animal);
    }

    public <T extends Person> void action(T person) {
        animalList.forEach(animal -> animal.eat(person));
    }
}
